﻿<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="renderer" content="webkit">
		<title>总管理登录</title>
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="icon" href="img/logo.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/clear.css" />
		<link rel="stylesheet" href="./css/officialLogin.css" />
	</head>

	<body class="officialLogin">
		<div class="officialLoginBox">
			<div class="officialLoginTit">
				<h3>多链钱包登录</h3>
			</div>
			<div class="userName inputBox">
				<input type="text" placeholder="请输入手机号获取图形验证码" id="phone" />
			</div>
			<div class="password inputBox">
				<input type="text" placeholder="输入图形验证码" maxlength="6" id="picCodeValue" />
				<div class="imgCode" id="picCode"></div>
			</div>
			<div class="password inputBox">
				<input type="text" placeholder="请输入图形验证码" maxlength="6" id="phone_code"/>
				<div class="imgCode" id="getCode" style="background-color: #CFDCF1;color:#3C5AAF;">获取验证码</div>
			</div>
			<input type='button' value="登 录" />
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<script src="dist/js/adminlte.min.js"></script>
		<script type="text/javascript" src="js/argument.js"></script>
		<script type="text/javascript">
			function getPicCode(phone){
				if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(phone))){
					alert('请输入正确手机号！');
					return false; 
				}
				$.ajax({	
					type: "post",
					url: url + "HomeGetPicCode",
					async: true,
					data: {
						data:JSON.stringify({phone:phone})
					},
					contentType:'application/x-www-form-urlencoded',
					dataType: "json",
					success: function(res) {
						if(res.status == 1) {
							var resJSON = res.data.pic_code;
							$("#picCode").html('<img src="data:image/png;base64,'+resJSON+'">')
						} else {
							alert(res.error)
						}
					}
				})
			}
			$("#phone").change(function(){
				var phone = $(this).val();
				getPicCode(phone)
			})
			
			$("#picCode").click(function(){
				var phone = $("#phone").val();
				getPicCode(phone)
			})
			

			var btn = $("#getCode");
			var wait = 60;
			var isPress = false;
			$("#getCode").click(function() {
					if($("#phone").val()==""){
						alert('请填写手机号');
						return false;
					}
					if($("#picCodeValue").val()==""){
						alert('请填写图形验证码');
						return false;
					}
					function time() {
						if(wait == 0) {
							btn.html("获取验证码");
							wait = 60;
							isPress = false;
						} else {
							btn.html("重新获取" + wait + "s");
							wait--;
							setTimeout(function() {
								time();
							}, 1000)
						}
					}
					console.log(isPress)
					if(isPress) {
						return;
					} else {
						isPress = true;
						var code;
						$.ajax({	
							type: "post",
							url: url + "HomeCommitPicCode",
							async: true,
							data: {
								data:JSON.stringify({phone:$("#phone").val(),pic_code:$("#picCodeValue").val()})
							},
							contentType:'application/x-www-form-urlencoded',
							dataType: "json",
							success: function(res) {
								if(res.status == "1") {
									time();
									return;
								} else {
									isPress = false;
									alert(res.error);
								}
							}
						})
					}
				});
				
			$("input[type=button]").click(function() {
				var phone = $("#phone").val(),
					phone_code = $("#phone_code").val();
				var data = {
					phone: phone,
					phone_code: phone_code
				}
				$.ajax({	
					type: "post",
					url: url + "HomeCommitPhoneCode",
					async: true,
					data: {
						data:JSON.stringify(data)
					},
					contentType:'application/x-www-form-urlencoded',
					dataType: "json",
					success: function(res) {
						if(res.status == 1) {
							var resJSON = res.data;
							localStorage.setItem("official_wallet_name", resJSON.base_info.phone);
							localStorage.setItem("official_wallet_token", resJSON.token);
							localStorage.setItem("official_wallet_id", resJSON.base_info.id);
							window.location.href = 'officialAPI.html';
							return false;
						} else {
							alert(res.error)
						}
					}
				})
			})
		</script>
	</body>

</html>